package com.kaili.basic.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.kaili.basic.pojo.dto.BaseSuggestionAddDto;
import com.kaili.basic.pojo.dto.BaseSuggestionQueryDto;
import com.kaili.basic.pojo.entity.BaseSuggestion;
import com.kaili.basic.pojo.entity.BaseSuggestionExport;
import com.kaili.basic.mapper.BaseSuggestionMapper;
import com.kaili.basic.service.BaseSuggestionService;
import com.kaili.common.util.LoginDetailUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;


/**
 * Created by renzhikun on 18-10-10.
 */
@Service
public class BaseSuggestionServiceImpl implements BaseSuggestionService{

@Autowired
private BaseSuggestionMapper suggestionMapper;

    @Override
    public void addBaseSuggestion(BaseSuggestion baseSuggestion) {
        baseSuggestion.setCreateBy(LoginDetailUtils.getCurrentEmployeeId().longValue());
        baseSuggestion.setCreateTime(new Date());
        suggestionMapper.addBaseSuggestion(baseSuggestion);
    }

    @Override
    public String getMaxSuggestionCode() {
        return suggestionMapper.getMaxSuggestionCode();
    }

    @Override
    public Page<BaseSuggestion> queryBaseSuggestion(Page<BaseSuggestion> page, BaseSuggestionQueryDto dto) {
        List<BaseSuggestion> baseSuggestionList =  suggestionMapper.queryBaseSuggestion(page,dto);
        return page.setRecords(baseSuggestionList);
    }

    @Override
    public List<BaseSuggestionExport> querySuggestionExport(Map<String, Object> map) {
        return suggestionMapper.querySuggestionExport(map);
    }


}
